package com.alibaba.citrus.cr.sales.plan.facade.service.salesplan.publish;

import com.alibaba.citrus.cr.sales.plan.sdo.SalesPlanStatScItemSDO;

import com.epoch.app.crplatformenhance.sdo.OrganizationSDO;
import lombok.Data;
import org.apache.commons.compress.utils.Lists;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @author tinglang
 * @date 2021/12/23.
 */
@Data
public class OrgScItemPlanInfo {

    private String organizationId;

    /* 部门列表 */
    private List<OrganizationSDO> organizationSDOS;

    /* 组织下的计划货品清单 */
    private Map</* scItemId */ String, SalesPlanStatScItemSDO> orgSalesPlanStatScItemInfoMap;

    /* 组织下部门的计划货品清单 */
    private Map</* departmentId */ String , Map</* scItemId */ String, SalesPlanStatScItemSDO>> departSalesPlanStatScItemInfoMap;

    public List<String> calculateDepIdsByScItemId(String scItemId, Set<String> whiteDepIds){
        List<String> depIds = Lists.newArrayList();
        for(String depId: departSalesPlanStatScItemInfoMap.keySet()){
            if(departSalesPlanStatScItemInfoMap.get(depId).get(scItemId)!=null && whiteDepIds.contains(depId)){
                depIds.add(depId);
            }
        }

        return depIds;
    }

}
